package com.tyk.bookstore.front.comment.model.vo;

import com.tyk.bookstore.front.common.core.util.FileUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author tyk
 * @description 评论
 */
@Data
public class CommentVo {

    @Schema(description = "ID")
    private Long id;

    @Schema(description = "会员ID")
    private Long memberId;

    @Schema(description = "会员名称")
    private String memberName;

    @Schema(description = "会员头像")
    private String memberAvatar;

    @Schema(description = "评论内容")
    private String content;

    @Schema(description = "评价等级")
    private Long star;

    @Schema(description = "评论时间")
    private LocalDateTime createTime;

    @Schema(description = "回复数量")
    private Long replyNum;

    @Schema(description = "回复")
    List<Reply> children;

    @Data
    public static class Reply {

        @Schema(description = "ID")
        private Long id;

        @Schema(description = "会员ID")
        private Long memberId;

        @Schema(description = "会员名称")
        private String memberName;

        @Schema(description = "会员头像")
        private String memberAvatar;

        @Schema(description = "回复内容")
        private String content;

        @Schema(description = "评论时间")
        private LocalDateTime createTime;

        public Reply setMemberAvatar(String memberAvatar) {
            this.memberAvatar = FileUtil.fullFilePath(memberAvatar);
            return this;
        }
    }

    public CommentVo setMemberAvatar(String memberAvatar) {
        this.memberAvatar = FileUtil.fullFilePath(memberAvatar);
        return this;
    }
}
